Skip to content

fix(fleet-queue): list fetches in pages, --task verifies one task (#7871) - #8476

Merged
dezren39 merged 3 commits into
mainfrom
queue/14563-7871-list-limit
Nov 11, 2026
Merged

dezren39 merged 3 commits into
mainfrom
queue/14563-7871-list-limit

Conversation

@dezren39

@dezren39 dezren39 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Fixes #7871 (task 14563).

Problem (reproduced live, 2026-11-11)

  • fleet queue list --status done --limit 101 returns 101 rows; --limit 102, 200 and 500 print (no tasks) with exit 0.
  • A status with few rows returns rows at a large limit (failed, 7 rows, at --limit 200); a status with many rows returns empty (cancelled, 361 rows, at --limit 200). The failure tracks the returned row count (~101 max per response), and the client rendered an unusable/empty reply as a silent (no tasks) — which reads as "task does not exist".
  • The done list is ordered priority/created (oldest first), so a just-completed task is not findable in list output at any working limit.

Fix

  • Client (client.rs): list now fetches in pages of LIST_PAGE_SIZE = 100 (list_pages, a pure paging plan), advancing an offset until the requested limit is met or a short page ends the result. A /list reply whose rows is missing or not an array is now a loud exit-3 error (list_rows) instead of a silent empty list. New list --task <id> filter verifies a single task's current status regardless of list size or ordering.
  • Broker, PostgREST path (queue_broker.rs): /list honors offset (offset= param) and task (id=eq.).
  • Broker, Turso path (turso_queue.rs): verb_list honors offset (OFFSET) and task (id = ?).
  • Offsets pass through one shared guard (list_offset_or_default: absent = 0, negative clamps to 0) at both broker trust boundaries.

Tests (oracle-named)

  • list_pages_cover_the_limit_exactly — paging-plan oracle: pages are contiguous, ascending, each within the page size, and sum exactly to the requested limit; offset clamping cases.
  • list_rows_rejects_a_reply_without_a_rows_array — the silent-empty oracle: Null / rows-less / non-array replies are errors; an explicit empty array is a legitimate empty list.
  • Full suite: cargo test -p fleet-queue --all-features — 198 passed, 0 failed on the laptop.

Acceptance: a large --limit now returns rows page by page (never a silent empty), and fleet queue list --task <id> verifies a just-completed task's status=done directly. Live verification against the production broker follows once this lands and the fleet binary is rebuilt/redeployed by the usual flip.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

)

A single /list response reliably carries at most ~100 rows; above that the reply came back unusable and cmd_list rendered it as a silent (no tasks) with exit 0. Fetch any limit in 100-row pages over a broker-honored offset (PostgREST offset= and Turso OFFSET), refuse a rows-less reply loudly, and add list --task <id> (id filter on both backends) so a worker can verify a just-completed task directly. Task 14563.
@dezren39
dezren39 requested a review from a team as a code owner November 11, 2026 02:59
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 40 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 637d406a-82b1-40b2-b903-0236357d9149
Commits

Reviewing files that changed from the base of the PR and between 8411117 and b16222d.

Files selected for processing: 3

  • pkgs/fleet/crates/fleet-queue/src/client.rs
  • pkgs/fleet/crates/fleet-queue/src/queue_broker.rs
  • pkgs/fleet/crates/fleet-queue/src/turso_queue.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T04:07:10.310771Z b16222d New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 73f11772f6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

crate::client::list_offset_or_default(req.get("offset").and_then(|o| o.as_i64()));
let mut path = format!(
"tasks?select={select}&queue=eq.{}&order=priority.asc,created_at.asc&limit={limit}",
"tasks?select={select}&queue=eq.{}&order=priority.asc,created_at.asc&limit={limit}&offset={offset}",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add a unique tie-breaker to the paginated list order

When multiple tasks share a priority and creation timestamp, this ordering does not uniquely order them. The new client fetches independent pages with different LIMIT/OFFSET values—for example, --limit 101 requests 100 rows followed by 1—so PostgreSQL can order tied tasks differently between requests, causing duplicate tasks and omitted tasks even without concurrent queue updates. Previously, fetching a single response did not introduce this cross-page inconsistency. Append id.asc to the PostgREST ordering and the equivalent ID tie-breaker to the Turso ordering.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the tie-breaker commit at the current PR head. Both paginated list orderings now end in a unique id tie-breaker: the PostgREST path orders priority.asc,created_at.asc,id.asc and the Turso path orders (priority IS NULL), priority ASC, created_at ASC, id ASC — so independent LIMIT/OFFSET page fetches cannot duplicate or omit rows that tie on priority and created_at. The remaining created_at-only orderings are single-row picks (LIMIT 1) and the separate creation-outbox list, which the paged fetch does not use. cargo test -p fleet-queue --all-features: 198 pass, 0 fail before the main merge; branch is on current main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fleet queue list: large --limit silently returns zero rows; no way to verify a recent completion

1 participant